package com.xinz.action;


import java.util.Calendar;
import java.util.Date;

import com.xinz.Constants;
import com.xinz.cache.PlayerCache;
import com.xinz.model.Player;
import com.xinz.protocal.Session;
import com.xinz.service.PlayerService;

public class BaseAction {

	/**
	 * 获取Player
	 * @return
	 */
	protected Player getPlayer() {
		Session session = Session.getCurrent();
		String pid = (String) session.getTag(Constants.SESSION_ID);
		Player player = PlayerCache.instance.getPlayer(pid);
		// 隔天重置数据
		PlayerService.resetData(player);
		// 流程日志数据
		session.setTag(Constants.FLOW_GOLD, player.getGold());
		session.setTag(Constants.FLOW_MONEY, player.getMoney());
		session.setTag(Constants.FLOW_SCORE, player.getScore());
		session.setTag(Constants.FLOW_START_TIME, System.currentTimeMillis());
		return player;
	}
}
